<!DOCTYPE html>
<html lang="cn" window-frame="solid-with-shadow" window-icon="../images/icon/icon.ico">
<head>
    <meta charset="UTF-8">
    <title>BS Redis Desktop Client</title>
    <link rel="stylesheet" href="/css/icon.css">
    <style>
        @import "../css/define.css";

        * {
            margin: 0;
            padding: 0
        }

        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            background: #fff;
        }

        .body {
            width: 100%;
            height: 100px;
            flow: horizontal;
            horizontal-align: left;
            vertical-align: middle;
        }
        .body .type{
            width: 80px;
            font-size: 40px;
            text-align: center;
            line-height: 60px;
        }
        .body .msg{
            width: 140px;
            word-break: break-all;
            font-size: 14px;
        }
        .controller {
            height: 50px;
            padding: 0 15px;
            flow: horizontal;
            border-spacing: *;
            horizontal-align: center;
            vertical-align: middle;
        }
        .normal{
            color: @content;
        }
        .success{
            color: @success;
        }
        .info{
            color: @info;
        }
        .warning{
            color: @warning;
        }
        .error{
            color: @error;
        }
    </style>
</head>
<body>
<div styleset="#title-bar" role="window-caption">
    <div class="title-bar-title">
        <img class="app-icon" src="/images/icon/app.png" height="16px"/>
        <span class="app-name"></span>
    </div>
    <div class="title-bar-action">
        <button class="btn exit" id="exit"></button>
    </div>
</div>

<div id="body"></div>
<div class="controller">
    <button class="btn btn-primary" style="width: 70px" id="ok">确定</button>
    <button class="btn btn-primary" style="width: 70px" id="cancel">取消</button>
</div>
<script type="module">
    import tools from "../js/tools";

    class Confirm extends Element {
        constructor(...props) {
            super(...props);
        }

        renderType() {
            switch (tools.getParameters().type) {
                case "success":
                    return <i class={"icon icon-check"}></i>
                case "info":
                    return <i class={"icon icon-information"}></i>
                case "error":
                    return <i class={"icon icon-lightbulb-on"}></i>
                case "warning":
                    return <i class={"icon icon-weather-pouring"}></i>
                default:
                    return <i class={"icon icon-information"}></i>
            }
        }

        parseType() {
            switch (tools.getParameters().type) {
                case "success":
                    return "success"
                case "info":
                    return "info"
                case "error":
                    return "error"
                case "warning":
                    return "warning"
                default:
                    return "normal"
            }
        }

        render() {
            return <div class={"body" }>
                <div class={"type "+ this.parseType()}>
                   {this.renderType()}
                </div>
                <div class={"msg "+ this.parseType()}>
                    {tools.getParameters().msg}
                </div>
            </div>
        }
    }

    document.$(".app-name").innerText = tools.getParameters().title || "确认内容"
    document.$("#body").patch(<Confirm></Confirm>)
    document.on("click", "#ok", () => {
        tools.getView().close(true)
    })
    document.on("click", "#cancel", () => tools.getView().close("close"))
    document.on("click","#exit",()=>tools.getView().close("close"))
</script>
</body>
</html>